package cmd

import (
	"fmt"
	"os"

	"github.com/fatih/color"
)

const (
	ExitSuccess = iota
	ExitError
	ExitBadConnection
	ExitInvalidInput // for txn, watch cmd
	ExitBadFeature   // provided a valid flag with an unsupported value
	ExitInterrupted
	ExitIO
	ExitBadArgs = 128
)

var ErrorStyleFunc = color.New(color.FgRed).SprintFunc()

func ExitWithError(code int, err error) {
	fmt.Fprintln(os.Stderr, ErrorStyleFunc("[ERROR]"), err)
	os.Exit(code)
}
